// A strange lift
#include <iostream>
#include <queue>
using namespace std;

struct node
{
    int step;
    int floor;
    bool visited;
    int times;
};


int main()
{
    ios::sync_with_stdio(false);
    int N, A, B;
    struct node building[200];
    struct node a;
    queue<struct node> Q;
    bool found;
    while (true)
    {
        found = false;
        cin >> N >> A >> B;
        A--;
        B--;
        if (N == 0)
        {
            break;
        }
        for (int i = 0; i < N; i++)
        {
            cin >> building[i].step;
            building[i].floor = i;
            building[i].visited = false;
            building[i].times = 0;
        }
        while(!Q.empty())
        {
            Q.pop();
        }
        Q.push(building[0]);
        while(!Q.empty())
        {
            a = Q.front();
            Q.pop();
            if(a.floor == B)
            {
                found = true;
                break;
            }
            if(a.floor - a.step >= 0)
            {
                if (!building[a.floor - a.step].visited)
                {
                    building[a.floor - a.step].visited = true;
                    building[a.floor - a.step].times += (a.times+1);
                    Q.push(building[a.floor - a.step]);
                }
            }
            if(a.floor + a.step < N)
            {
                if (!building[a.floor + a.step].visited)
                {
                    building[a.floor + a.step].visited = true;
                    building[a.floor + a.step].times += (a.times + 1);
                    Q.push(building[a.floor + a.step]);
                }
            }
        }
        if(found)
        {
            cout << a.times << endl;
        }
        else
        {
            cout << -1 << endl;
        }
    }
}